home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5606 < prev    next >
Encoding:
Text File  |  1996-08-05  |  6.1 KB  |  137 lines

  1. Newsgroups: comp.lang.c
  2. Path: uu4news.netcom.com!zodiac!szh
  3. From: szh@zcon.com (Syed Zaeem Hosain)
  4. Subject: Re: What to do when feof() is NOT feof()
  5. Message-ID: <1996Feb19.225604.3390@zcon.com>
  6. Sender: szh@zcon.com (Syed Zaeem Hosain)
  7. Nntp-Posting-Host: zodiac
  8. Reply-To: szh@zcon.com
  9. Organization: Z Consulting Group
  10. References: <4g9tph$5ss@spectator.cris.com>
  11. Date: Mon, 19 Feb 1996 22:56:04 GMT
  12.  
  13. In article <4g9tph$5ss@spectator.cris.com>, aubrey@concentric.net (Aubrey Harrison) writes:
  14. >In article <1996Feb19.063026.29889@zcon.com>, szh@zcon.com∞ says...
  15. >[snip]
  16. >>On my SunOS system, there is no such ascii 26 byte denoting end of file
  17. >>and fgets will *not* terminate in this manner. The point is that by
  18. >>making such incorrect responses (like you did by insisting on this
  19. >>point) is just plain wrong. It has nothing to do with the language or
  20. >>how the end of files are denoted in most operating systems. Even in
  21. >>PC's running MSDOS, there is no such requirement that there *must* be
  22. >>an ascii 26 at the end of text files. Certain editors (Brief is an
  23. >>example. microEMacs is another) can easily be configured to create such
  24. >>ascii files without this byte.
  25. >>
  26. >>Note that even the EOF result returned (look in stdio.h) has nothing to
  27. >>do with the actual byte at the end of the file.
  28. >>
  29. >>The bottom line still is: please do not offer answers if you do not
  30. >>know the correct answer.
  31. >
  32. >Nowhere did I say a file had to end with an ascii 26.
  33.  
  34. Agreed, you did not say that exactly. But let's look at your *exact*
  35. words, shall we? In <4g4vpp$52f@spectator.cris.com> you wrote:
  36.  
  37.     I think if you open the file in "text" mode the end of the file
  38.     is indicated by the EOF marker (ASCII 26 I believe).
  39.  
  40. Would you not agree that my interpretation and response in my post is a
  41. reasonable way to deal with what you actually said? I will clarify
  42. further. When I spoke of my SunOS system, I was careful to say:
  43.  
  44.     no such ascii 26 byte denoting end of file
  45.  
  46. This is because in SunOS, a file is simply a file and no qualification
  47. is needed. When I spoke of PC systems, I said:
  48.  
  49.     Even in PC's running MSDOS, there is no such requirement that
  50.     there *must* be an ascii 26 at the end of text files.
  51.  
  52. The point is that I used the qualifier "text" when talking about PC
  53. system files because of the specific response I was making to your
  54. post. Again, this is because of the interpretation I made of your
  55. words.
  56.  
  57. But if this was not a correct way of reading your words, my apologies!
  58.  
  59. >What I said (or I am 
  60. >trying to say), and this is true which is why I can't understand all this 
  61. >commotion... On an MS-DOS machine, using Microsoft C, if you do not tell fopen 
  62. >you are reading a binary file by using the "rb" parameter inputs such as fgets 
  63. >will stop reading and return end-of-file if it encounters an ascii 26 in the 
  64. >file. i.e. If the 654th byte of a 60,000 line file is an ascii 26, fgets will 
  65. >only read 654 bytes of the file.
  66.  
  67. The commotion is caused by the fact is that you did not limit your
  68. original answer properly - your post effectively indicated that dealing
  69. with byte value 26 was some general problem in C and fgets would fail.
  70. This is a misleading and incorrect answer - just because the MSDOS
  71. operating system OR Microsoft C do this behavior does not mean that the
  72. C LANGUAGE is supposed to behave in this manner.
  73.  
  74. Yes, Dan was less than tactful in his response, but (and this is
  75. important) he made a correct observation. In active newsgroups like
  76. this, when we are all trying to learn from experts and be helpful to
  77. others, posts that create further confusion only result in long-term
  78. problems. There have been times when we all have been very frustrated
  79. by people not following the simple rules that exist, and Dan merely has
  80. less patience than others.
  81.  
  82. >Once again, the original message did not indicate what OS or compiler the 
  83. >person was using.
  84.  
  85. Exactly! Which is why your MS-DOS and Microsoft C specific response,
  86. without qualification, could have sent that person barking up the wrong
  87. tree.
  88.  
  89. >I should have been clearer in my response that I was 
  90. >referring to MS-DOS and Microsoft C.
  91.  
  92. Yes, absolutely! This is good form.
  93.  
  94. >I only responded because I have had the 
  95. >exact same problem and tracked it down to the fact that while the file I was 
  96. >reading was a "text" file there were a few bytes (including ascii 26) that were 
  97. >killing fgets and signalling end-of-file when it was not. Maybe he has some 
  98. >other problem, maybe he has the same problem. I don't know, and you don't know. 
  99. >I think the notion that the only help that could or should ever be given is an 
  100. >exact diagnoses and cure to a problem is a little ridiculous and unpractical. 
  101.  
  102. Not really impractical at all. In many situations, exact answers on C
  103. language issues can be (and often do get) provided by people who have
  104. the expertise. Let them do so if you do not have the right answer.
  105.  
  106. The bottom line is:
  107.  
  108. 1. If your answer is indeed restricted to a specific OS and/or compiler
  109. and/or system implementation, then please do say so. This leads to less
  110. confusion for the people asking questions.
  111.  
  112. 2. We try very strongly to ask questions (and respond to them) in
  113. non-system-specific ways because this is a newsgroup dedicated to
  114. LANGUAGE discussions about C. When people need system-specific
  115. information, there are plenty of other newsgroup dedicated to that
  116. purpose (such as comp.os.msdos.programmer, comp.unix.programmer,
  117. comp.os.ms-windows.programmer, etc.)
  118.  
  119. 3. If you do not know the correct answer, please do not answer. There
  120. are sufficient experts here who will post the correct answer (as and
  121. when and if needed) in due time.
  122.  
  123. And to this, I would always add a general admonishment (which does not
  124. apply to your post): please read the FAQ before posting questions and
  125. replies, no matter how right you think you are. I have been using C for
  126. over 14 years and still get surprised on occasion by certain constructs.
  127. I still look in the FAQ before I ask or answer a question.
  128.  
  129.                                 Z
  130.  
  131.  
  132. -- 
  133. -------------------------------------------------------------------------
  134. | Syed Zaeem Hosain          P. O. Box 610097            (408) 441-7021 |
  135. | Z Consulting Group        San Jose, CA 95161             szh@zcon.com |
  136. -------------------------------------------------------------------------
  137.